package com.kate.mall.product.service.impl;

import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kate.mall.common.utils.PageUtils;
import com.kate.mall.common.utils.Query;

import com.kate.mall.product.dao.GoodsSpecificationDao;
import com.kate.mall.product.entity.GoodsSpecificationEntity;
import com.kate.mall.product.service.GoodsSpecificationService;


@Service("goodsSpecificationService")
public class GoodsSpecificationServiceImpl extends ServiceImpl<GoodsSpecificationDao, GoodsSpecificationEntity> implements GoodsSpecificationService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<GoodsSpecificationEntity> page = this.page(
                new Query<GoodsSpecificationEntity>().getPage(params),
                generatorWrapper(params)
        );

        return new PageUtils(page);
    }
    private  QueryWrapper<GoodsSpecificationEntity> generatorWrapper(Map<String, Object> params){
        QueryWrapper<GoodsSpecificationEntity> queryWrapper = new QueryWrapper<>();
        if(params.containsKey("goods_id")){
            queryWrapper.lambda().eq(GoodsSpecificationEntity::getGoodsId,Integer.parseInt(String.valueOf(params.get("goods_id"))));
        }

        //TODO 要不要写逻辑删除条件？？？
        return queryWrapper;
    }

}